package com.ruoyi.web.controller.api.task;

import com.ruoyi.common.utils.DateUtil;
import com.ruoyi.system.service.IPAskTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Configuration //读取配置
@EnableScheduling // 2.开启定时任务
public class AskTypeTask {

    //日志
    private static final Logger logger = LoggerFactory.getLogger(AskTypeTask.class);
    @Resource
    private IPAskTypeService ipAskTypeService;

    /**
     * 每天0点执行
     */
    @Scheduled(cron = "0 0 0 */1 * ?")
    public void updateAskTypeReadNum() {
        // cron : 0 0 0 */1 * ?
        logger.info("---AskTypeTask------bargain stop status change task: Execution Time - {}", DateUtil.nowDateTime());
        try {
            this.ipAskTypeService.updateAskTypeReadNum();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("AskTypeTask" + " | msg : " + e.getMessage());
        }
    }
}
